<template>
  <view class="wrap">
    <view class="search flex-jb flex-ac">
      <u-search
        placeholder="搜索"
        v-model="contact"
        :showAction="false"
        bgColor="#fff"
		@search="searchClick"
		:clearabled="true"
		 @clear="searchClear"
      ></u-search>
    </view>
	
	<view class="list">
		<view class="item flex-jb flex-ac" v-for="(item,index) in list" :key="index">
			<view class="left flex-ac">
				<image src="/static/icon/icon_mine.png" mode="widthFix"></image>
				<view class="name">{{item.contact || ''}}</view>
				<view class="name">{{item.contactPhone}}</view>
			</view>
			<view class="del" @click="delAuthorizer(item.id)">删除</view>
		</view>
	</view>
	
	<view class="btn"  @click="$route('/pages/certigier/add')">添加授权人</view>
	
  </view>
</template>

<script>
import { getToken } from "@/utils/auth";

import { getAuthorizerList , delAuthorizer} from "@/api";
import { log } from "util";
export default {
  components: {
  },
  data() {
    return {
      list:[],
	  contactPhone:'',
	  contact:'',
    };
  },
  computed: {
    isLogin() {
      return this.$store.state.isLogin;
    },
    userInfo() {
      return this.$store.state.userInfo;
    },
  },
  onShow() {
	  this.contact = '';
	this.getAuthorizerList();
  },
  methods: {
	getAuthorizerList(){
		let userInfo = wx.getStorageSync('userInfo')
		let phone  = userInfo.phonenumber
		getAuthorizerList({
			deptId:uni.getStorageSync('deptId'),
			phone:phone,
			contact:this.contact
		}).then(res => {
			this.list = res.data
		})
	},
	// 删除
	delAuthorizer(id){
		this.$modal("是否删除当前授权人", () => {
			delAuthorizer(id).then(res =>{
				this.$toast("成功");
				this.getAuthorizerList()
			})
		  
		});		
	},
	// 搜索
	searchClick(){
		this.getAuthorizerList()
	},
	searchClear(){
		this.contact = '';
		this.getAuthorizerList()
	},
  },
};
</script>

<style lang="less" scoped>
	.wrap{
		.search {
		  padding: 30rpx 30rpx 0 30rpx;
		}
		.list{
			padding: 30rpx;
			.item{
				background: #FFFFFF;
				border-radius: 16rpx 16rpx 16rpx 16rpx;
				padding: 30rpx;
				margin-bottom: 30rpx;
				.left{
					image{
						width: 48rpx;
					}
					.name{
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 30rpx;
						color: #000000;
						margin-left: 20rpx;
					}
				}
				.del{
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 30rpx;
					color: #138E57;
				}
			}
		}
		.btn{
			height: 80rpx;
			background: linear-gradient( 83deg, #48B453 0%, #2C9F79 100%);
			border-radius: 200rpx 200rpx 200rpx 200rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #FFFFFF;
			line-height: 80rpx;
			text-align: center;
			margin: 0 70rpx;
		}
	}
</style>
